<!DOCTYPE html>
<html>
<meta charset="utf-8"> 
<head>
	<title>产线一览</title>
<link rel="stylesheet" type="text/css" href="css/common.css">
<style type="text/css">
.u-container{
	position: relative;
	width: 100%;
	height: 140px;
	margin: 0 auto;
	margin-top: 40px;
	overflow-x: hidden;
	overflow-y: auto;
}
.u-container p{
	display: none;
}
.u-container .machine{
	float: left;
	height: 110px;
	text-align: center;
	-webkit-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    filter: grayscale(100%);
}
.u-container .machine img{
	height: 100%;
}
.u-container .machine:hover{
	background: #29abe2;
}
.u-container .machine.machinenormal{
	-webkit-filter: none;
    -o-filter: none;
    -moz-filter: none;
    -ms-filter: none;
    filter: none;
}
.u-container .machine.machinestop{
	-webkit-filter: grayscale(100%);
    -o-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    filter: grayscale(100%);
}
.u-container .machine.machineerror{
	-webkit-filter: none;
    -o-filter: none;
    -moz-filter: none;
    -ms-filter: none;
    filter: none;
}
.u-container .machine.machinedisconnect{
	background: #777;
}
.u-container .machine.machineerror:hover{
	background: #f00;
}
.u-container .machine.machinedisconnect:hover,.u-container .machine.machinestop:hover{
	opacity: .7;
}
.undone{
	-webkit-filter: grayscale(100%); /* Chrome, Safari, Opera */
    filter: grayscale(100%);
    background: #d0d0d0;
}
.u-datacon{
	position: relative;
	width: 100%;
	height: 540px;
}
.u-leftline{
	position: relative;
	width: 50%;
	height: 540px;
	float: left;
}
.u-indexinfos{
	position: relative;
	float: left;
	width: 98%;
	margin-left: 1%;
	height: 84px;
	border: 1px solid #aaa;
	text-align: left;
	padding-bottom: 20px;
	line-height: 20px;
}
.u-indexinfos h2,.u-indexinfos p{
	float: left;
	line-height: 20px;
	margin-left: 6px;
	font-size: 12px;
}
.u-indexinfos p{
	margin-right: 12px;
}
.u-indexinfos .u-line{
	width: 100%;
	height: 0px;
	margin-top: 20px;
	border-bottom: 1px solid #aaa;
}
.m-btns{
	position: absolute;
	width: 68%;
	left: 31%;
	top: 270px;
	height: 150px;
	text-align: center;
	overflow-x: hidden;
	overflow-y: auto;
}
.m-btns .m-btn{
	float: left;
	display: block;
	width: 80px;
	height: 50px;
	line-height: 50px;
	margin: 10px;
	color: #29abe2;
	border: 1px solid #29abe2;
}
.m-btn:before{
	content: '';
	display: inline-block;
	width: 10px;
	height: 10px;
	margin-right: 2px;
	border-radius: 50%;
	background: #16e14d;
}
.u-chartcon{
	position: relative;
	float: left;
	width: 98%;
	margin-left: 1%;
	height: 550px;
	margin-top: 10px;
	text-align: center;
	border: 1px solid #aaa;
	overflow: hidden;
}
.u-chart{
	position: relative;
	float: left;
	width: 95%;
	height: 300px;
	margin: 172px 0 0 36px;
	border-left: 2px solid #252525;
	border-bottom: 2px solid #252525;
}
.u-chartleft{
	position: absolute;
	display: block;
	height: 330px;
	width: 20px;
	left: 2px;
	top: 162px;
}
.u-chartleft span{
	float: left;
	width: 20px;
	height: 16px;
	line-height: 16px;
	margin-bottom: 14px;
}
.u-changetime{
	position: absolute;
	width: 100%;
	height: 30px;
	left: 0;
	top: 10px;
}
.u-changetime input.datainp{
	text-indent: 7px;
	height: 27px;
	-webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
	border: 1px solid #d0d0d0;
	margin-left: 4px;
}
.u-start{
	float: left;
	margin-left: 10px;
}
.u-end{
	float: left;
	margin-left: 10px;
}
.u-confirmbtn{
	float: left;
	margin-left: 9px;
	border-top: 1px solid #96d1f8;
    background: #54b6f7;
    background: -webkit-gradient(linear, left top, left bottom, from(#54b6f7), to(#54b6f7));
    background: -webkit-linear-gradient(top, #54b6f7, #54b6f7);
    background: -moz-linear-gradient(top, #54b6f7, #54b6f7);
    background: -ms-linear-gradient(top, #54b6f7, #54b6f7);
    background: -o-linear-gradient(top, #54b6f7, #54b6f7);
    padding: 5px 10px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0;
    -moz-box-shadow: rgba(0,0,0,1) 0 1px 0;
    box-shadow: rgba(0,0,0,1) 0 1px 0;
    text-shadow: rgba(0,0,0,.4) 0 1px 0;
    color: white;
    font-size: 14px;
    font-family: Georgia, Serif;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
}
.u-confirmbtn:hover {
   border-top-color: #4f9ccf;
   background: #4f9ccf;
   color: #fcf7fc;
}
.u-auto{
	line-height: 27px;
}
.u-chartbottom{
	position: absolute;
	display: block;
	width: 40px;
	height: 20px;
	line-height: 20px;
	margin: 0;
	left: -30px;
	bottom: -22px;
}
.u-chartbars{
	float: left;
	position: relative;
	height: 100%;
	width: 35px;
	margin-left: 20px;
	-webkit-transform: rotateX(180deg);
}
.u-chartbars .u-mname{
	position: absolute;
	left: 3px;
	top: -22px;
	line-height: 16px;
	width: 14px;
	height: 20px;
	font-size: 12px;
	-webkit-transform: rotateX(-180deg);
	word-wrap:break-word;
	word-break:break-all
}
.u-product{
	float: left;
	height: 46px;
	width: 100%;
	bottom: 0;
	left: 0;
	background: #f5d73e;
}
.u-break{
	float: left;
	width: 100%;
	background: #f44336;
}
.u-error{
	float: left;
	width: 100%;
	background: #009fff;
}
.u-select{
	position: absolute;
	right: 0;
	top: 46px;
	width: 140px;
	height: 100px;
}
.u-intro{
	width: 100%;
	float: left;
	height: 30px;
	vertical-align: middle;
	text-align: left;
}
.u-intro span{
	display: inline-block;
	line-height: 30px;
}
.u-intro input{
	display: inline-block;
	vertical-align: middle;
	margin-left: 12px;
}
.u-intro label{
	color: #999;
	font-size: 12px;
}
.u-intro1,.u-intro2,.u-intro3{
	display: inline-block;
	float: left;
	margin-top: 5px;
	margin-right: 8px;
	width: 20px;
	height: 20px;
}
.u-intro1{
	background: #f5d73e;
}
.u-intro2{
	background: #f44336;
}
.u-intro3{
	background: #009fff;
}
.u-static{
	display: inline-block;
	width: 88px;
	height: 30px;
	background: #54b6f7;
	line-height: 30px;
	text-align: center;
	margin-left: 1%;
	font-size: 6px;
}
.u-limitline{
	position: absolute;
	left: 0;
	bottom: 100px;
	width: 100%;
	height: 1px;
	border-bottom: 1px solid #C1CDCD;
}
.u-limitline span{
	display: block;
	position: absolute;
	right: 5px;
	line-height: 14px;
	top: -14px;
	font-size: 12px;
}
.refreshtime{
	width: 30px;
	padding-left: 5px;
	height: 20px;
	border-radius: 6px;
    border: 1px solid #d0d0d0;
    margin-left: 6px;
}
.u-chartbarcon{
	position: relative;
    float: left;
    width: 8000px;
    height: 100%;
}
.u-chartlinecon{
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
}
	.tips{
		position: absolute;
		top: 0;
		left: 0;
		width: 200px;
		min-height:50px;
		background: rgba(255,255,255,0.8);
		color: red;
		z-index: 1000;
		padding: 10px;
		display: none;

		border: 1px solid #dfdfdf;
		border-radius: 5px;
		line-height: 24px;
	}
</style>
<link rel="stylesheet" type="text/css" href="css/machine.css">
</head>
<body>
<div class="tips">
	<ul><li>aaa</li></ul>
</div>
<div class='u-head'>
   <div class="u-headcon">
	<!--<a href="index.html"><div class="u-mainpage" >回到首页</div></a>-->
	   <a href="#"><div style="position: absolute;height: 40px;top: 13px;left: 8px;color: #fff;line-height: 40px;text-align: center;" >产线监控软件 iMointor V1.0</div></a>
	<h3 >产线一览</h3>
	   <div class="changeLang">
		   <p class="u-lang"><span>中文</span><span>English</span></p>
		   <div isopen="true" class="changeLangBtn"></div>
	   </div>
</div>
</div>
<div class="u-container lineA">
</div>
<div class="u-container lineB">
</div>
<!--<a href="statistics_print.html" target="_blank"><div class="u-static">印刷机分析1</div></a>
<a href="statistics_print2.html" target="_blank"><div class="u-static">印刷机分析2</div></a>-->
<a href="statistics_error.html" target="_blank"><div class="u-static">异常分析1</div></a>
<a href="statistics_error2.html" target="_blank"><div class="u-static">异常分析2</div></a>
<!--<a href="statistics_stove.html" target="_blank"><div class="u-static">烧结炉分析</div></a>

<a href="statistics_drying2.html" target="_blank"><div class="u-static">干燥炉分析</div></a>
	<a href="statistics_activation.html" target="_blank"><div class="u-static">上料机稼动率</div></a>
	<a href="statistics_activationprint.html" target="_blank"><div class="u-static">印刷机稼动率</div></a>-->
<div class="u-datacon">
	<div class="u-leftline">
		<div class="u-indexinfos">
			<h2>产线1</h2>
			<div class="u-line"></div>
			<p>当前班次：<span class="a_s1"></span></p>
			<p>理论产能：<span class="a_s2"></span></p>
			<p>炉前产能：<span class="a_s3"></span></p>
			<p>炉后产能：<span class="a_s4"></span></p>
			<br>
			<!--<p>补片率&lt;!&ndash;炉前碎片数（碎片率）&ndash;&gt;：<span class="a_s5"></span></p>-->
			<!--<p>丢片率&lt;!&ndash;炉后碎片数（碎片率）&ndash;&gt;：<span class="a_s6"></span></p>-->
			<!--<p >待机时间：<span class="a_s16"></span></p>-->
			<!--<br>-->
			<!--<p>1道湿重：<span class="a_s7"></span></p>
			<p>2道湿重：<span class="a_s8"></span></p>
			<p>3道湿重：<span class="a_s9"></span></p>
			<p>4道湿重：<span class="a_s10"></span></p>
			<p>1道烘干率：<span class="a_s11"></span></p>
			<p>2道烘干率：<span class="a_s12"></span></p>
			<p>3道烘干率：<span class="a_s13"></span></p>-->
			<p>当前效率：<span class="a_s14"></span></p>
			<p>当前良率：<span class="a_s15"></span></p>
		</div>
		<div class="u-chartcon u-chartcon1">
			<div class="u-changetime">
				<div class="u-start" ><label>开始时间</label><input type="text" class="datainp startDate1" readonly/></div>
				<div class="u-end" ><label>结束时间</label><input type="text" class="datainp endDate1" readonly/></div>
				<div class="u-confirmbtn u-confirmbtn1">确认</div>
				<div class="u-auto"><input class="u-autorefresh1" type="checkbox" ><span data-localize="index.refresh">自动刷新</span><label style="font-size: 12px;color: #999;margin-left: 10px;" data-localize="index.time">时间范围</label><input type="text" class="refreshtime refreshtime1" /><span style="font-size: 12px;color: #999;margin-left: 6px;" data-localize="index.mininute">分钟</span></div>
			</div>
			<div class="u-select">
				<div class="u-intro"><span class="u-intro1" ></span><span>产品</span></div>
				<div class="u-intro" style="display: none"><span class="u-intro2"></span><span>碎片</span><input type="checkbox" class="u-equm" checked /><label>隐藏</label></div>
				<div class="u-intro"  style="display: none"><span class="u-intro3" ></span><span>品质异常</span><input type="checkbox" class="u-broken" checked  /><label>隐藏</label></div>
			</div>
			<div class="u-chart u-chart1">
				<div class="u-chartbarcon u-chartbarcon1"></div>
				<div class="u-chartlinecon u-chartlinecon1"></div>
			</div>
			<p class="u-chartleft u-chartleft1">
			</p>
			<!-- <p class="u-chartbottom">设备</p> -->
		</div>
	</div>
	<div class="u-leftline">
		<div class="u-indexinfos">
			<h2>产线2</h2>
			<div class="u-line"></div>
			<p>当前班次：<span class="b_s1"></span></p>
			<p>理论产能：<span class="b_s2"></span></p>
			<p>炉前产能：<span class="b_s3"></span></p>
			<p>炉后产能：<span class="b_s4"></span></p>
			<br>
			<!--<p>补片率&lt;!&ndash;炉前碎片数（碎片率）&ndash;&gt;：<span class="b_s5"></span></p>-->
			<!--<p>丢片率&lt;!&ndash;炉后碎片数（碎片率）&ndash;&gt;：<span class="b_s6"></span></p>-->

			<!--<br>-->
			<!--<p>1道湿重：<span class="b_s7"></span></p>
			<p>2道湿重：<span class="b_s8"></span></p>
			<p>3道湿重：<span class="b_s9"></span></p>
			<p>4道湿重：<span class="b_s10"></span></p>
			<p>1道烘干率：<span class="b_s11"></span></p>
			<p>2道烘干率：<span class="b_s12"></span></p>
			<p>3道烘干率：<span class="b_s13"></span></p>-->
			<p>当前效率：<span class="b_s14"></span></p>
			<p>当前良率：<span class="b_s15"></span></p>
		</div>
		<div class="u-chartcon u-chartcon2">
			<div class="u-changetime">
				<div class="u-start" ><label>开始时间</label><input type="text" class="datainp startDate2" readonly/></div>
				<div class="u-end" ><label>结束时间</label><input type="text" class="datainp endDate2" readonly/></div>
				<div class="u-confirmbtn u-confirmbtn2">确认</div>
				<div class="u-auto"><input class="u-autorefresh2" type="checkbox"><span>自动刷新</span><label style="font-size: 12px;color: #999;margin-left: 10px;">时间范围</label><input type="text" class="refreshtime refreshtime2" /><span style="font-size: 12px;color: #999;margin-left: 6px;">分钟</span></div>
			</div>
			<div class="u-select">
				<div class="u-intro"><span class="u-intro1" ></span><span>产品</span></div>
				<div class="u-intro"  style="display: none"><span class="u-intro2" ></span><span>碎片</span><input type="checkbox" checked  class="u-equm" /><label>隐藏</label></div>
				<div class="u-intro"  style="display: none"><span class="u-intro3" ></span><span>品质异常</span><input type="checkbox" checked  class="u-broken" /><label>隐藏</label></div>
			</div>
			<div class="u-chart u-chart2">
				<div class="u-chartbarcon u-chartbarcon2"></div>
				<div class="u-chartlinecon u-chartlinecon2"></div>
			</div>
			<p class="u-chartleft u-chartleft2"></p>
			<!-- <p class="u-chartbottom">设备</p> -->
		</div>
	</div>
</div>
<!-- <div class="m-btns">
	<a href="feeder.html" class="m-btn">上料机</a>
	<a href="print.html" class="m-btn">印刷机1</a>
	<a href="drying.html" class="m-btn">干燥炉1</a>
	<a href="cache.html" class="m-btn">缓存机</a>
	<a href="print.html" class="m-btn">印刷机2</a>
	<a href="drying.html" class="m-btn">干燥炉2</a>
	<a href="rotate.html" class="m-btn">翻转机</a>
	<a href="print.html" class="m-btn">印刷机3</a>
	<a href="drying.html" class="m-btn">干燥炉3</a>
	<a href="cache.html" class="m-btn">缓存机</a>
	<a href="print.html" class="m-btn">印刷机4</a>
	<a href="translate.html" class="m-btn">搬片机</a>
	<a href="stove.html" class="m-btn">烧结炉</a>
	<a href="joinstove.html" class="m-btn">接烧结炉</a>
	<a href="backcheck.html" class="m-btn">背检</a>
	<a href="frontcheck.html" class="m-btn">正检</a>
	<a href="test.html" class="m-btn">测试机</a>
	<a href="sort.html" class="m-btn">分选机1</a>
	<a href="sort.html" class="m-btn">分选机2</a>
	<a href="sort.html" class="m-btn">分选机3</a>
</div> -->

<script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="js/common.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jedate.min.js"></script>
<script src="js/jquery.localize.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/language_cookie.js" type="text/javascript" charset="utf-8"></script>
<script>
var lastData = null,
	si=null,
	isFirst = true;
var url = getUrl("index");
if ('WebSocket' in window) {
    websocket = new WebSocket(url);
}else {
    alert('Not support websocket')
}

websocket.onerror = function () {
};

websocket.onopen = function (event) {
}
function resetMStatus(){
	//$('.machine').removeClass('machinedisconnect');
	$('.machine').removeClass('machineerror');
	//$('.machine').removeClass('machinestop');
	$('.machine').removeClass('machinenormal');
}


websocket.onmessage = function (event) {
    si = JSON.parse(event.data.replace(/\bNaN\b/g, "null"));
    if (!lastData) {
    	lastData = si;
    }
    resetMStatus();

    /*for (var i = 1; i < 16; i++) {
    	$('.a_s'+i).html(si['status'+i+'_a']);
    	$('.b_s'+i).html(si['status'+i+'_b']);
    }*/
    
    //si.line2 = [{"equipment_no":"B1","status":"1"},{"equipment_no":"B2","status":"2"},{"equipment_no":"B3","status":"0"}]
    for (var i = 0,len = si.line1?si.line1.length:0; i < len; i++) {
		switch (si.line1[i].status) 
		{ 
		  case "0":
		  	//$('.lineA .equipment'+si.line1[i].equipment_no).addClass('machinestop');
		  	break; 
		  case "1":
		  	$('.lineA .equipment'+si.line1[i].equipment_no).addClass('machinenormal');
		  	var picid = $('.lineA .equipment'+si.line1[i].equipment_no).attr('data-picid');
		  	$('.lineA .equipment'+si.line1[i].equipment_no).find('img').attr("src","image/m"+picid+".png")
		  	break;
		  case "2":
		  	$('.lineA .equipment'+si.line1[i].equipment_no).addClass('machineerror');
		  	var picid = $('.lineA .equipment'+si.line1[i].equipment_no).attr('data-picid');
		  	$('.lineA .equipment'+si.line1[i].equipment_no).find('img').attr("src","image/m"+picid+"-"+picid+".png");
		  	$('.lineA .equipment'+si.line1[i].equipment_no).attr('data-error',  si.line1[i].equipment_no);



		  	break;
		  default:
		  	//$('.lineA .equipment'+si.line1[i].equipment_no).addClass('machinestop');
		  	break;
		}
	}
	for (var i = 0,len = si.line2?si.line2.length:0; i < len; i++) {
		switch (si.line2[i].status) 
		{ 
		  case "0":
		  	break; 
		  case "1":
		  	$('.lineB .equipment'+si.line2[i].equipment_no).addClass('machinenormal');
		  	var picid = $('.lineB .equipment'+si.line2[i].equipment_no).attr('data-picid');
		  	$('.lineB .equipment'+si.line2[i].equipment_no).find('img').attr("src","image/m"+picid+".png")
		  	//$('.lineB .equipment'+si.line2[i].equipment_no).addClass('machinenormal');
		  	break;
		  case "2":
		  	//$('.lineB .equipment'+si.line2[i].equipment_no).addClass('machineerror');
		  	$('.lineB .equipment'+si.line2[i].equipment_no).addClass('machineerror');
		  	var picid = $('.lineB .equipment'+si.line2[i].equipment_no).attr('data-picid');
		  	$('.lineB .equipment'+si.line2[i].equipment_no).find('img').attr("src","image/m"+picid+"-"+picid+".png");
		  	$('.lineB .equipment'+si.line2[i].equipment_no).attr('data-error',  si.line2[i].equipment_no);
		  	break;
		  default:
		  	break;
		}
	}
    console.log(si);

    lastData = si;
}

window.onbeforeunload = function(){
	websocket.close();
}
</script>
<script type="text/javascript">
$(function() {


    $(".machine").on('mouseover',function (e) {
       // debugger;
		if($(this).hasClass('machineerror')){
            var top=e.pageY;
            var left=e.pageX;
            $(".tips").css({top:top,left:left});
            var html = $(".machine").attr("data-error");
            $(".tips ul").html(html);
            $(".tips").css('display','block');
		}

    });
    $(".machine").on('mouseout',function (e) {
        $(".tips").css('display','none');
	});
	$('.u-chartcon1 .u-equm').click(function(){
		if($('.u-chartcon1 .u-equm').is(':checked')) {
		    $('.u-chartcon1 .u-break').hide();
		}else{
			$('.u-chartcon1 .u-break').show();
		}
	});
	$('.u-chartcon1 .u-broken').click(function(){
		if($('.u-chartcon1 .u-broken').is(':checked')) {
		    $('.u-chartcon1 .u-error').hide();
		}else{
			$('.u-chartcon1 .u-error').show();
		}
	});
	$('.u-chartcon2 .u-equm').click(function(){
		if($('.u-chartcon2 .u-equm').is(':checked')) {
		    $('.u-chartcon2 .u-break').hide();
		}else{
			$('.u-chartcon2 .u-break').show();
		}
	});
	$('.u-chartcon2 .u-broken').click(function(){
		if($('.u-chartcon2 .u-broken').is(':checked')) {
		    $('.u-chartcon2 .u-error').hide();
		}else{
			$('.u-chartcon2 .u-error').show();
		}
	});
	var interval1,interval2;
	$('.u-autorefresh1').click(function(){
		if($('.u-autorefresh1').is(':checked')) {
			statisticsRender(1);
			interval1 = setInterval("statisticsRender(1)",60000);
		}else{
			clearInterval(interval1);
		}
	})
	$('.u-autorefresh2').click(function(){
		if($('.u-autorefresh2').is(':checked')) {
			statisticsRender(2);
			interval2 = setInterval("statisticsRender(2)",60000);
		}else{
			clearInterval(interval2);
		}
	})
	jeDate({
        dateCell:".endDate1",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:true,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00"
    });
    jeDate({
        dateCell:".startDate1",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:true,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00"
    });
    jeDate({
        dateCell:".endDate2",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:true,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00"
    });
    jeDate({
        dateCell:".startDate2",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:true,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00"
    });
    $('.u-confirmbtn1').click(function(){
    	if($('.u-autorefresh1').is(':checked')) {
    		statisticsRender(1);
			interval1 = setInterval("statisticsRender(1)",60000);
		}else{
			clearInterval(interval1);
			statisticsRender(1);
		}
		//statisticsRender(1);
	})
	$('.u-confirmbtn2').click(function(){
		if($('.u-autorefresh2').is(':checked')) {
			statisticsRender(2);
			interval2 = setInterval("statisticsRender(2)",60000);
		}else{
			clearInterval(interval2);
			statisticsRender(2);
		}
	})
	//$('.u-product').eq(1).stop().animate({"height":"60px"});
});
function getData(line,startDate,endDate,url){
    var res = "";
    $.ajax({  
        type:'get',      
        url: url,
        async : false, 
        dataType: "json",
        data:{"line":line,"startDate":startDate,"endDate":endDate},  
        success:function(data){
            if (data.resultCode == 200 && data.resultMessage == "OK") {
                res = data;
            }
        },
        error:function(){
            console.log("fail");
        }  
    });
    return res;
}
function statisticsRender(sorder){
    var aaa = [0],
		html = "",
		linehtml = "";
	var url = getUrl('statistics_index'),
		line,startDate,endDate;
	if (sorder == 1) {
		line = "1";
		if($('.u-autorefresh1').is(':checked')) {
			setTimeA();
		}
	}else if (sorder == 2) {
		line = "2";
		if($('.u-autorefresh2').is(':checked')) {
			setTimeB();
		}
	}
	var startDate = $('.startDate'+sorder).val();
	var endDate = $('.endDate'+sorder).val();
	var mes = getData(line,startDate,endDate,url);

    console.log(mes);
	var maxCapacity = mes.resultObject.maxLimit;
	for (var i = 0,len = mes.resultObject.list?mes.resultObject.list.length:0; i < len; i++) {
		var height1 = parseInt(mes.resultObject.list[i].outPutNum)*300/maxCapacity;
		var height2 = parseInt(mes.resultObject.list[i].piecesNum)*300/maxCapacity;
		var height3 = parseInt(mes.resultObject.list[i].qualityNum)*300/maxCapacity;
		// if (height1 > 260) {
		// 	height1 = 300;
		// }
		if(html.indexOf(mes.resultObject.list[i].equipmqntName)==-1){
            if(getCookie("somoveLanguage")=="zh"){
                html += '<div class="u-chartbars"><div class="u-product" style="height:'+height1+'px"></div><div class="u-break" style="height:'+height2+'px"></div><div class="u-error" style="height:'+height3+'px"></div><span class="u-mname">'+mes.resultObject.list[i].equipmqntName+'</span></div>';
            }else if (getCookie("somoveLanguage")=="en"){
                html += '<div class="u-chartbars"><div class="u-product" style="height:'+height1+'px"></div><div class="u-break" style="height:'+height2+'px"></div><div class="u-error" style="height:'+height3+'px"></div><span class="u-mname">'+mes.resultObject.list[i].equipmqntNameEn+'</span></div>';

            }else {
                html += '<div class="u-chartbars"><div class="u-product" style="height:'+height1+'px"></div><div class="u-break" style="height:'+height2+'px"></div><div class="u-error" style="height:'+height3+'px"></div><span class="u-mname">'+mes.resultObject.list[i].equipmqntName+'</span></div>';
            }
		}

	}
	var limit1 = parseInt(mes.resultObject.totalCapacity)*300/maxCapacity,
		limit2 = parseInt(mes.resultObject.ldhsCapacity)*300/maxCapacity,
		limit3 = parseInt(mes.resultObject.hamlCapacity)*300/maxCapacity;
    if(mes.resultObject.totalCapacity&&mes.resultObject.totalCapacity!=0) {
        linehtml += '<div class="u-limitline" style="bottom:'+limit1+'px"><span>目标产能（'+mes.resultObject.totalCapacity+'）</span></div>';
    }
	if(mes.resultObject.ldhsCapacity&&mes.resultObject.ldhsCapacity!=0) {
        linehtml += '<div class="u-limitline" style="bottom:' + limit2 + 'px"><span>上料机产能（' + mes.resultObject.ldhsCapacity + '）</span></div>';
    }
	if(mes.resultObject.hamlCapacity&&mes.resultObject.hamlCapacity!=0){
        linehtml += '<div class="u-limitline" style="bottom:'+limit3+'px"><span>测试机产能（'+mes.resultObject.hamlCapacity+'）</span></div>';
	}

	var labelhtml = "";
    for (var i = 0; i < 11; i++)  {
        var innum = maxCapacity - i*(maxCapacity/10);
        var innum = Math.floor(innum/100)*100;
        labelhtml += '<span>'+innum+'</span>';
	}
	$('.u-chartbarcon'+sorder).html("");
	$('.u-chartbarcon'+sorder).append(html);
	$('.u-chartlinecon'+sorder).html("");
	$('.u-chartlinecon'+sorder).append(linehtml);
	$('.u-chartleft'+sorder).html("");
	$('.u-chartleft'+sorder).append(labelhtml);
}
function setTimeA(){
	var time = new Date();
	var now = getNowFormatDate(time),past;
	var timelenth = $('.refreshtime1').val()?$('.refreshtime1').val():10;
	$('.endDate1').val(now);

	time.setMinutes(time.getMinutes() - timelenth, time.getSeconds(), 0);
	past = getNowFormatDate(time);
	$('.startDate1').val(past);
}
function setTimeB(){
	var time = new Date();
	var now = getNowFormatDate(time),past;
	var timelenth = $('.refreshtime2').val()?$('.refreshtime2').val():10;
	$('.endDate2').val(now);

	time.setMinutes(time.getMinutes() - timelenth, time.getSeconds(), 0);
	past = getNowFormatDate(time);
	$('.startDate2').val(past);
}
function statisticsTarget(){
    var url = getUrl("statistics_target");
    var res = "";
    $.ajax({
        type:'get',
        url: url,
        async : true,
        dataType: "json",
        success:function(data){
            console.log(data.resultObject);
            if (data.resultCode == 200 && data.resultMessage == "OK") {
                var sivalue = data.resultObject;
                console.log(sivalue);
                for (var i = 1; i < 16; i++) {
                    $('.a_s'+i).html(sivalue['status'+i+'_a']);
                    $('.b_s'+i).html(sivalue['status'+i+'_b']);
                }
            }
        },
        error:function(){
            console.log("fail");
        }
    });

}
function getEquipmentSort(){
    var url = getUrl("equipmentSort");
    var res = "";
    $.ajax({
        type:'get',
        url: url,
        async : true,
        dataType: "json",
        success:function(data){
            console.log(data.resultObject);
            if (data.resultCode == 200 && data.resultMessage == "OK") {
                var listA = data.resultObject.listA;
                var listB = data.resultObject.listB;
                console.log(listA);
                console.log(listA.length);
                var lineAHtml="";
                var lineBHtml="";
                for (var i = 0; i < listA.length; i++) {
                    var equipment=listA[i];
                    lineAHtml+="<a href=\""+equipment.URL+"\"><div class=\"machine equipmentA"+equipment.EQUIPMENT_ID+"\" data-picid=\""+equipment.PIC_ID+"\" data-error=\"\"><img src=\"image/m"+equipment.PIC_ID+".png\"></div></a>\n" +
                        "\t<p class=\"m-btn\">"+equipment.EQUIPMENT_NAME+"</p>";
                }
                for (var i = 0; i < listB.length; i++) {
                    var equipment=listB[i];
                    lineBHtml+="<a href=\""+equipment.URL+"\"><div class=\"machine equipmentB"+equipment.EQUIPMENT_ID+"\" data-picid=\""+equipment.PIC_ID+"\" data-error=\"\"><img src=\"image/m"+equipment.PIC_ID+".png\"></div></a>\n" +
                        "\t<p class=\"m-btn\">"+equipment.EQUIPMENT_NAME+"</p>";
                }
                $('.lineA').html(lineAHtml);
                $('.lineB').html(lineBHtml);
            }
        },
        error:function(){
            console.log("fail");
        }
    });

}
statisticsTarget();
getEquipmentSort();
</script>

</body>
</html>